import ipaddress
import platform
import os
for ip in ipaddress.ip_network('192.168.0.0/24'):
    Ping_re = os.popen('ping %s'%ip)
    result = Ping_re.read()
    Ping_re.close()
    ttl = 'TTL'
    if ttl in result:
        f = open('192.txt','a+')
        f.write(str(ip)+'\n')
        f.close()
    else:
        continue